package std.javax.swing.start;

import javax.swing.*;
import java.awt.*;

public class Quick {
    private static void createAndShowGUI() {
        //Create and set up the window.
        JFrame frame = new JFrame("HelloWorldSwing");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setBounds(100, 100, 100, 100);
        frame.setSize(new Dimension(300, 300));
        //Add the ubiquitous "Hello World" label.
        Container pane = frame.getContentPane();

        JLabel label = new JLabel("Hello World");
        label.setBounds(0,0,100,200);
        JButton button = new JButton("这是一个按钮");
        button.addActionListener(e -> {
            System.out.println(e.getActionCommand());
            System.out.println(e);
        });
        pane.setSize(300, 300);
        pane.setLayout(new BorderLayout());
        pane.add(label);
        pane.add(button);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(Quick::createAndShowGUI);
    }
}


